package com.controller;

import com.common.Result;
import com.entity.ArticleData;
import com.service.ArticleDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * User的路由接口服务
 * 
 * @author 
 *
 */
@RestController
@RequestMapping("pcApi")
public class ArticleDataController {

	/** UserService服务 */
	@Autowired
	private ArticleDataService articleDataService;

	/**
	 * 通过id查询User数据的方法
	 * @param id
	 * @return
	 */
	@ResponseBody
	@GetMapping(value = "/article/data/{id}", produces = {"application/json;charset=UTF-8"})
	public ArticleData findOne(@PathVariable(name="id") int id) {
		return articleDataService.findOne(id);
	}

	/**
	 * 新增数据
	 * @param id
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/article/data/create", produces = {"application/json;charset=UTF-8"})
	public Result create(@RequestBody ArticleData bean) {
		return articleDataService.create(bean);
	}

    @ResponseBody
    @PostMapping(value = "/article/data/like", produces = {"application/json;charset=UTF-8"})
	public Result like(@RequestBody ArticleData bean) {
	    return articleDataService.like(bean);
    }


}
